/*
 * xAPBSCcommand.java
 *
 * Java class used to send xAP BSC command messages
 *
 * Copyright (c) 2009 Daniel Berenguer <dberenguer@usapiens.com>
 *
 * This file is part of the jxAP project.
 *
 * OPNODE is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * OPNODE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with canTracer; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * 02/11/09 by Daniel Berenguer : first version
 */

package xAP;

/********************************************************************************************
 * xAPBSCcommand class
 *
 *********************************************************************************************/
public class xAPBSCcommand extends xAPBSCmessage
{
   /********************************************************************************************
    * Member variables
    ********************************************************************************************/

   /********************************************************************************************
    * xAPBSCcommand
    *
    * Class constructor
    *
    * 'Target'     xAP target address
    *
    ********************************************************************************************/
    public xAPBSCcommand(String Target, Object value)
    {
        version = drvCore.xAP_Version;
        xClass = "xAPBSC.cmd";
        uid = drvCore.xAP_BaseUID + ":0000";
        source = drvCore.xAP_SourceAddr;
        target = Target;
        hbody = "output.state.1";

        message = "xap-header\n{\nv=" + version + "\nhop=1\nuid=" + uid + "\nclass=" + xClass + "\nsource="
                + source + "\ntarget=" + target + "\n}\n" + hbody + "\n{\nid=*\n";

        if (value.getClass() == xAPBSCstate.class)
        {
            xAPBSCstate bscState = (xAPBSCstate)value;
            message = message + "state=" + bscState.toString() + "\n}\n";
        }
        else if (value.getClass() == xAPBSClevel.class)
        {
            xAPBSClevel bscLevel = (xAPBSClevel)value;
            message = message + "level=" + bscLevel.toString() + "\n}\n";
        }
        else if (value.getClass() == xAPBSCtext.class)
        {
            xAPBSCtext bscText = (xAPBSCtext)value;
            message = message + "text=" + bscText.toString() + "\n}\n";
        }
    }
}
